package com.wedimob.slideshare;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import com.wedimob.slideshare.bo.AbstractBO;
import com.wedimob.slideshare.source.Source;

public class SearchCriteria extends AbstractBO<SearchCriteria> {

    private String keyword;
    private KeyWordType keyWordType;
    private SortBy sortBy;
    private int begin;
    private int limit;
    private List<Source> sources = new ArrayList<Source>();

    public SearchCriteria(String keyword, SortBy sortBy, int begin, int limit) {
        super();
        this.keyword = keyword;
        this.sortBy = sortBy;
        this.begin = begin;
        this.limit = limit;
    }

    public String getKeyword() {
        return keyword;
    }

    public KeyWordType getKeyWordType() {
        return keyWordType;
    }

    public void setKeyWordType(KeyWordType keyWordType) {
        this.keyWordType = keyWordType;
    }

    public SortBy getSortBy() {
        return sortBy;
    }

    public int getLimit() {
        return limit;
    }

    public SearchCriteria addSource(Source src) {
        sources.add(src);
        return this;
    }

    public int getBegin() {
        return begin;
    }

    public List<URL> getURLs() {
        List<URL> result = new ArrayList<URL>();
        for (Source src : sources) {
            result.addAll(src.getStrategy().generateUrl(this));
        }
        return result;
    }
}
